function getObjSize(obj) {
	var ww = jQuery(window).width();
	var wh = jQuery(window).height();
	var dw = obj.width();
	var dh = obj.height();
	var objh = obj.height();// 浮动对象的高度
	var objw = obj.width();// 浮动对象的宽度
	var objt = (wh - dh) / 2 + jQuery(window).scrollTop();
	var objl = (ww - dw) / 2 + jQuery(window).scrollLeft();
	return {
		height : objh,
		width : objw,
		top : objt,
		left : objl
	};
};
// 页面遮罩插件
(function(jQuery) {
	jQuery
			.extend({
				documentMask : function(options) {
					// 扩展参数
					var op = jQuery.extend({
						opacity : 0.7,
						z : 10000,
						bgcolor : '#000'
					}, options);
					var st, sl, ch, cw, width, height;
					height = jQuery("body").height();
					width = jQuery("body").width();
					if (document.documentElement
							&& document.documentElement.scrollTop) {
						st = document.documentElement.scrollTop;
						sl = document.documentElement.scrollLeft;
						cw = document.documentElement.scrollWidth;
						ch = document.documentElement.scrollHeight;
					} else if (document.body) {
						st = document.body.scrollTop;
						sl = document.body.scrollLeft;
						cw = document.body.scrollWidth;
						ch = document.body.scrollHeight;
					}
					// 创建一个 Mask 层，追加到 document.body
					if (height < ch) {
						height = ch;
					}
					if (width < cw) {
						width = cw;
					}
					var mask = jQuery('<div class="jquery_addmask"> </div>')
							.appendTo(document.body).css({
								position : 'absolute',
								top : '0px',
								left : '0px',
								'z-index' : op.z,
								width : width,
								height : height,
								'background-color' : op.bgcolor,
								opacity : 0
							}).fadeIn('slow', function() {
								// 淡入淡出效果
								jQuery(this).fadeTo('slow', op.opacity);
							}).bind("click",function() {
								// 单击事件，Mask 被销毁
								jQuery(this).fadeTo('slow', 0, function() {
									jQuery(this).trigger("maskclose"); 
									jQuery(this).remove();
								});
							});

					return mask;
				}
			});
})(jQuery);
/**
 * 日期格式化
 * 
 * @param {}
 *            d 输入日期 例：20110915222430
 * @return {} 返回格式化日期 2011年09月15日 22:24:30
 */
DateFormat = function(d) {
	date = d.toString();
	var year = date.substr(0, 4);
	var month = date.substr(4, 2);
	var day = date.substr(6, 2);
	var hour = date.substr(8, 2);
	var min = date.substr(10, 2);
	var sec = date.substr(12, 2);
	return year + "年" + month + "月" + day + " " + hour + ":" + min + ":" + sec;
};

Date.prototype.format = function(format){

	var o = {
	"M+" : this.getMonth()+1, //month
	"d+" : this.getDate(),     //day
	"h+" : this.getHours(),    //hour
	      "m+" : this.getMinutes(), //minute
	      "s+" : this.getSeconds(), //second
	      "q+" : Math.floor((this.getMonth()+3)/3), //quarter
	      "S" : this.getMilliseconds() //millisecond
	   }

	   if(/(y+)/.test(format)) {
	    format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
	   }

	   for(var k in o) {
	    if(new RegExp("("+ k +")").test(format)) {
	      format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
	    }
	   }
	return format;
	};
/**
 * 扩展js function对象的代理方法
 * 
 * @param {}
 *            obj
 * @param {}
 *            args
 * @param {}
 *            appendArgs
 * @return {}
 */
Function.prototype.createDelegate = function(obj, args, appendArgs) {
	var method = this;
	return function() {
		var callArgs = args || arguments;
		if (appendArgs === true) {
			callArgs = Array.prototype.slice.call(arguments, 0);
			callArgs = callArgs.concat(args);
		} else if (typeof appendArgs === 'number' && isFinite(appendArgs)) {
			callArgs = Array.prototype.slice.call(arguments, 0); // copy
			// arguments
			// first
			var applyArgs = [ appendArgs, 0 ].concat(args); // create method
			// call params
			Array.prototype.splice.apply(callArgs, applyArgs); // splice them
			// in
		}
		;
		return method.apply(obj || window, callArgs);
	};
};
/**
 * 扩展js function对象的集成方法
 * 
 * @param {}
 *            parentClass
 */
Function.prototype.Extends = function(parentClass) {
	var Bs = new Function();
	Bs.prototype = parentClass.prototype;
	this.prototype = new Bs();
	this.prototype.Super = parentClass;
	this.prototype.constructor = this;
};

var Tfeet = {
	version : "1.0",
	widgets : {},
	apply : function(o, c, defaults) {
		if (defaults) {
			Tfeet.apply(o, defaults);
		}
		if (o && c && typeof c == 'object') {
			for ( var p in c) {
				o[p] = c[p];
			}
		}
		return o;
	}
};
/**
 * 基类
 */
Tfeet.Base = function() {
	this.uid = null;
	this.uname = null;
	this.key = null;
	this.data = {};
};
/**
 * 单一Tfeet对象
 */
Tfeet.widgets.tfeetNode = function(config) {
	this.tfid = null;
	this.body = null;
	this.marker = null;
	this.commentList = null;
	this.data = null;
	this.toolbar = null;
	this.bodyCfg = '<div class="c_box">'
			+ '<a name="#${tfeet.tfid}"></a>'
			+ '<div class="c_b_head"><img src="${avator}" /></div>'
			+ '<div class="c_b_text">'
			+ '<div class="b_t_node">'
			+ '<div class="t_node_1">${uname}</div>'
			+ '<div class="t_node_2">${aboutme}</div>'
			+ '</div>'
			+ '<div class="b_t_node">'
			+ '<div class="t_node1_11">行记：</div>'
			+ '<div class="t_node1_22">${tfeet.text}</div>'
			+ '<div class="t_node1_33">'
			+ '<div imgContainer class="node1_33_m1"></div>'
			+ '<div class="node1_33_m2">${tfeet.location}</div>'
			+ '</div>'
			+ '<div class="t_node1_44">'
			+ '<div class="node1_44_m1">上传时间：${DateFormat(this.data.tfeet.datetime)}</div>'
			+ '<div class="node1_44_m2" toolbarContainer>'
			+ '</div></div></div></div>' 
			+ '<div commentsContainer></div>'
			+ '</div>';

	this.initComponent = function(config) {
		Tfeet.apply(this, config);
		this.readData();
	};
	// 渲染方法
	this.render = function() {
		this.body = jQuery.tmpl(this.bodyCfg, this.data);
		this.buildToolbar();
		this.buildImg();
		this.marker = new Tfeet.widgets.tfeetMarker({
			data : this.data,
			map : this.map
		});
	};

	// 读取数据
	this.readData = function() {
		if (this.data) {
			// 如果data不是json对象则尝试转换
			if (typeof (this.data) != "object") {
				this.data = eval("(" + this.data + ")");
			}
			this.tfid = this.data.tfeet.tfid;
		}
	};

	// 添加tfeet到list
	this.appendTo = function(container) {
		this.body.appendTo(container);
	};
	// 构建图片
	this.buildImg = function() {
		if (!this.data) {
			throw new Error("Tfeet的data错误。");
			return;
		} else {
			var img = jQuery('<img style="width:100px;height:100px;cursor:url(/static/cur/zoomin.cur),auto;"/>');
			img.attr("src", this.data.tfeet.image);
			img
					.bind(
							"click",
							function() {
								// 显示大图

								var showImgContainer = jQuery('<div style="position:absolute;z-index:10001;background-color:#000000;opacity:1"></div>');
								var showImg = jQuery('<img style="margin:5px;;cursor:url(/static/cur/zoomout.cur),auto;"/>');
								var showImgSrc = this.data.tfeet.image.replace(
										/_s./, "_n.");
								showImg.attr("src", showImgSrc);
								showImgContainer.append(showImg);
								var sizeObj = getObjSize(showImgContainer);
								showImgContainer
										.appendTo(jQuery.documentMask());
								showImgContainer.css({
									top : sizeObj.top,
									left : sizeObj.left
								});
							}.createDelegate(this));
			var imgContainer = this.body.find("DIV[imgContainer]");
			imgContainer.append(img);
			return;
		}
	};

	// 构建工具栏
	this.buildToolbar = function() {
		if (!this.data) {
			throw new Error("Tfeet的data错误。");
			return;
		} else {
			// 定位按钮
			this.toolbar = this.body.find("DIV[toolbarContainer]");
			this.toolbar.locBtn = jQuery('<a href="#" locBtn">定位</a>');
			this.toolbar.locBtn.bind('click', this.locTfeet);
			this.toolbar.favBtn = jQuery('<a href="#" favBtn>收藏</a>');
			this.toolbar.favBtn.bind('click', this.addFav);
			this.toolbar.unFavBtn = jQuery('<a href="#" favBtn>取消收藏</a>');
			this.toolbar.unFavBtn.bind('click', this.delFav);
			// 判断是《收藏》还是《取消收藏》
			if (this.data.tfeet.isfav == 0) {
				this.toolbar.curFavBtn = this.toolbar.favBtn;
			} else {
				this.toolbar.curFavBtn = this.toolbar.unFavBtn;
			}
			this.toolbar.weetBtn = jQuery('<a href="#" weetBtn>转发</a>');
			this.toolbar.weetBtn.bind('click', this.tfeetweet);

			this.toolbar.editBtn = jQuery('<a href="#" editBtn>修改</a>');
			this.toolbar.weetBtn.bind('click', this.editTfeet);
			this.toolbar.delBtn = jQuery('<span delBtn>删除</span>');
			this.toolbar.delBtn.bind('click', this.deltfeet);
			this.toolbar.commentBtn = jQuery('<span commentBtn>评论('
					+ this.data.tfeet.comments + ')</span>');
			this.toolbar.commentBtn.bind('click', this.loadComments);
			this.toolbar.append(this.toolbar.locBtn);
			this.toolbar.append(this.toolbar.curFavBtn);
			this.toolbar.append(this.toolbar.weetBtn);
			// 如果是自己的tfeet则显示修改与删除
			if (this.data.uid == this.uid) {
				this.toolbar.append(this.toolbar.editBtn);
				this.toolbar.append(this.toolbar.delBtn);
			}
			this.toolbar.append(this.toolbar.commentBtn);
		}
	};

	// 定位
	this.locTfeet = function() {
		for ( var i = 0; i < this.list.nodeList.length; i++) {
			this.list.nodeList[i].marker.marker.setAnimation(null);
		}
		this.marker.openInfoWindow();
		this.marker.marker.setAnimation(google.maps.Animation.BOUNCE);
	}.createDelegate(this);

	// 转发微博
	this.tfeetweet = function() {
		jQuery.ajax({
			url : "./i/tfeetweet",
			type : "post",
			dataType : "json",
			data : {
				comment : "",
				tfid : this.data.tfeet.tfid,
				srckey : this.key
			},
			success : function(data, textStatus) {

			}
		});
	}.createDelegate(this);
	// 修改tfeet
	this.editTfeet = function() {
		// todo
	};

	// 删除tfeet
	this.deltfeet = function() {
		jQuery.ajax({
			url : "./i/deltfeet",
			type : "post",
			dataType : "json",
			data : {
				tfid : this.data.tfeet.tfid,
				srckey : this.key
			},
			success : function(data, statusText) {
				if (statusText == "success") {
					// 删除对象
					this.body.remove();
					delete (this);
				}
			}.createDelegate(this)
		});
	}.createDelegate(this);

	// 收藏
	this.addFav = function() {
		jQuery.ajax({
			url : "./i/addFav",
			type : "post",
			dataType : "json",
			data : {
				uid : this.uid,
				tfid : this.data.tfeet.tfid,
				srckey : this.key
			},
			success : function(data, textStatus) {
				this.toolbar.curFavBtn.after(this.toolbar.unFavBtn);
				this.toolbar.curFavBtn.detach();
				this.toolbar.curFavBtn = this.toolbar.unFavBtn;
				return false;
			}.createDelegate(this)
		});
	}.createDelegate(this);

	// 取消收藏
	this.delFav = function() {
		jQuery.ajax({
			url : "./i/delFav",
			type : "post",
			dataType : "json",
			data : {
				uid : this.uid,
				tfid : this.data.tfeet.tfid,
				srckey : this.key
			},
			success : function(data, textStatus) {
				this.toolbar.curFavBtn.after(this.toolbar.favBtn);
				this.toolbar.curFavBtn.detach();
				this.toolbar.curFavBtn = this.toolbar.favBtn;
				return false;
			}.createDelegate(this)
		});
	}.createDelegate(this);

	// 获取评论列表
	this.loadComments = function() {
		if(this.commentList==null){
			this.commentList = new Tfeet.widgets.commentList({
				tfeet:this
			});
		}else{
			this.commentList.remove();
			delete this.commentList;
		}
	}.createDelegate(this);

	this.initComponent(config);
};
Tfeet.widgets.tfeetNode.Extends(Tfeet.Base);

/*******************************************************************************
 * tfeet列表
 */
Tfeet.widgets.tfeetList = function(config) {
	this.initComponent = function(config) {
		Tfeet.apply(this, config);
	};
	// [all] [self] [fav]
	this.type = "all";
	this.data = null;
	this.map = null;
	// 当前从第几条显示
	this.currentRecord = 0;
	// tfeetnode列表
	this.nodeList = new Array();
	this.render = function() {
		this.body = jQuery("#tfeetContent");
		this.body.html('');
		var bounds = new google.maps.LatLngBounds();
		for ( var i = 0; i < this.nodeList.length; i++) {
			var tfeet = this.nodeList[i];
			tfeet.render();
			bounds.extend(tfeet.marker.position);
			this.body.append(tfeet.body);
			// tfeet.appendTo(this.body);
		}
		this.map.body.fitBounds(bounds);
	};

	// 数据转换
	this.convertData = function() {
		if (this.data) {
			// 如果data不是json对象则尝试转换
			if (typeof (this.data) != "object") {
				this.data = eval("(" + this.data + ")");
			}
		}
	};

	// 加载数据
	this.load = function(type) {
		if (type) {
			this.type = type;
		}
		// url : "./i/getfeet/"+this.type+"/"+this.uid,
		//jQuery.get("/data/tfeetlist.json", {
		jQuery.get("./i/getfeet/"+this.type+"/"+this.uid, {
			tfid : this.currentRecord,
			type : this.type,
			srckey : this.key
		}, function(data) {
			this.nodeList = new Array();
			this.data = data;
			this.convertData();

			if (this.data["tfeets"] != null) {
				for ( var i = 0; i < this.data["tfeets"].length; i++) {
					var nodeData = this.data["tfeets"][i];
					var tfeet = new Tfeet.widgets.tfeetNode({
						data : nodeData,
						list : this,
						map : this.map
					});

					this.nodeList.push(tfeet);
				}
			}
			this.render();

		}.createDelegate(this));
	}.createDelegate(this);

	this.addTfeet = function() {

	};

	this.initComponent(config);
};
Tfeet.widgets.tfeetList.Extends(Tfeet.Base);
/** ***************************************************************** */
Tfeet.widgets.map = function(config) {
	this.container = null;
	this.body = null;
	this.centerPoint = new google.maps.LatLng(39.91, 116.41);
	this.mapType = google.maps.MapTypeId.HYBRID;
	this.zoomLevel = 11;
	this.initComponent = function(config) {
		Tfeet.apply(this, config);
	};
	this.render = function(mapContainer) {
		if (mapContainer == null) {
			mapContainer = this.container;
		}
		this.body = new google.maps.Map(mapContainer, {
			zoom : this.zoomLevel,
			center : this.centerPoint,
			mapTypeId : this.mapType
		});
	};
	this.initComponent(config);
};

Tfeet.widgets.tfeetMarker = function(config) {
	this.body = null;
	this.data = null;
	this.position = null;
	this.map = null;
	this.marker = null;
	this.bodyCfg = '<div class="infoWindow">'
			+ '<div class="infoWindow_img"><img src="${tfeet.image}"/></div>'
			+ '<div class="infoWindow_owner"><div><img src="${avator}" /></div><div>${uname}</div></div>'
			+ '<div class="infoWindow_content">${tfeet.text}</div>' + '</div>';
	this.initComponent = function(config) {
		Tfeet.apply(this, config);
		if (this.map == null || this.data == null) {
			return false;
		}
		this.render();
		this.infowindow = new google.maps.InfoWindow({
			content : this.body
		});
		this.marker = new google.maps.Marker({
			position : this.position,
			map : this.map.body
		});
		// 关闭窗口事件——关闭动画
		google.maps.event.addListener(this.infowindow, 'closeclick',
				function() {
					this.marker.setAnimation(null);
				}.createDelegate(this));
		google.maps.event.addListener(this.marker, 'click', function() {
			this.infowindow.open(this.map.body, this.marker);
		}.createDelegate(this));
	};
	this.openInfoWindow = function() {
		this.infowindow.open(this.map.body, this.marker);
	};
	this.closeInfoWindow = function() {
		this.infowindow.close();
	};
	this.render = function() {
		this.position = new google.maps.LatLng(this.data.tfeet.lat,
				this.data.tfeet.long);
		this.body = jQuery.tmpl(this.bodyCfg, this.data)[0].outerHTML;
	};
	this.initComponent(config);
};
/**
 * 评论
 */
Tfeet.widgets.comment = function(config) {
	this.cid = null;
	this.data = null;
	this.bodyCfg = '<li><div >${uname}:${comment}</div><div class="commentDate">${DateFormat(datetime)}</div><div class="commentBtnContain">{{if uid=='+this.uid+'}}<span class="commentBtn" commentDelBtn>删除</span>{{/if}}</div></li>';
	this.initComponent = function(config) {
		Tfeet.apply(this, config);
		this.readData();
	};
	this.readData = function(){
		if (this.data) {
			// 如果data不是json对象则尝试转换
			if (typeof (this.data) != "object") {
				this.data = eval("(" + this.data + ")");
			}
			this.cid = this.data.cid;
		}
	};
	this.render = function(){
		this.body = jQuery.tmpl(this.bodyCfg, this.data);
		this.body.find("span[commentDelBtn]").bind('click',this.del);
	};
	
	this.del = function(){
		jQuery.ajax({
			url : "./i/delComment",
			type : 'post',
			dataType : "json",
			data : {
				cid : this.cid,
				srckey : this.key
			},
			success : function(data, textStatus) {
				this.body.remove();
			}.createDelegate(this)
		});
	}.createDelegate(this);
	
	this.initComponent(config);
};

Tfeet.widgets.comment.Extends(Tfeet.Base);

/**
 * 评论列表
 */
Tfeet.widgets.commentList = function(config) {
	this.bodyCfg = '<ul commentListContainer class="commentUl"><li><div><textarea rows="1" cols="200" class="expand20-150"></textarea></div><div style="text-align:right;width:100%"><span commetBtn>评论</span></div></li></ul>';
	this.body = null;
	this.tfeet = null;
	//当前最后一条评论id 分页用
	this.currentPageComentId = 0;
	this.initComponent = function(config) {
		Tfeet.apply(this, config);
		this.load();
	};
	
	// 数据转换
	this.convertData = function() {
		if (this.data) {
			// 如果data不是json对象则尝试转换
			if (typeof (this.data) != "object") {
				this.data = this.data.replace(/\r/ig,"").replace(/\n/ig,""); 
				this.data = eval("(" + this.data + ")");
			}
		}
	};
	
	this.load = function() {
		// url：
		// http://tinyfeet.us/i/getfeetComments/1211?cid=0?srckey=sadfqweqwet
		//jQuery.get("/data/commentList.json"+this.tfid, {jQuery.get("./i/getComments/"+this.tfid, {
		jQuery.get("./i/getComments/"+this.tfeet.tfid, {
			cid : this.currentPageComentId,
			srckey : this.key
		}, function(data) {
			//this.nodeList = new Array();
			this.list = new Array();
			this.data = data;
			this.convertData();
			if (this.data["comments"] != null) {
				for ( var i = 0; i < this.data["comments"].length; i++) {
					var commentData = this.data["comments"][i];
					var comment = new Tfeet.widgets.comment({
						data:commentData
					});
					this.list.push(comment);
				}
			}
			this.render();

		}.createDelegate(this));
	}.createDelegate(this);
	this.render = function() {
		if(this.body!=null){
			this.body.remove();
		}
		this.body = jQuery.tmpl(this.bodyCfg, this.data);
		this.commentTxa = this.body.find("textarea[class*=expand]").TextAreaExpander();
		this.commentBtn = this.body.find("span[commetBtn]");
		this.commentBtn.bind('click',this.saveComment);
		for ( var i = 0; i < this.list.length; i++) {
			var comment = this.list[i];
			comment.render();
			this.body.append(comment.body);
			// tfeet.appendTo(this.body);
		}
		var container = this.tfeet.body.find("DIV[commentsContainer]");
		container.append(this.body);
		this.body.animate({  
			  opacity: 'show'
			}, 'slow');
		
	};
	
	this.remove = function(){
		this.body.remove();
	};
	
	this.saveComment = function(){
		var content = this.commentTxa.val();
		jQuery.ajax({
			url : "./i/addComment",
			type : 'post',
			dataType : "json",
			data : {
				uid : this.uid,
				tfid:this.tfeet.tfid,
				comment:content,
				srckey : this.key
			},
			success : function(data, textStatus) {
				debugger;
				if(data&&data.msg==200){
					var commentData = {
						uname:this.uname,
						cid:data.cid,
						uid:this.uid,
						comment:this.commentTxa.val(),
						datetime:data.date
					};
					var comment = new Tfeet.widgets.comment({
						data:commentData
					});
					this.list.push(comment);
					comment.render();
					this.tfeet.toolbar.commentBtn.html("评论("+this.tfeet.commentList.list.length+")");
					comment.body.insertBefore(this.body.find("li:eq(1)"));
					this.commentTxa.val("");
				}
			}.createDelegate(this)
		});
	}.createDelegate(this);
	this.initComponent(config);
};
Tfeet.widgets.commentList.Extends(Tfeet.Base);
/******************************************************************************/
Tfeet.widgets.addTfeetWindow = function(config){
	this.bodyCfg='<div style="width: 430px;margin:5px 10px 0px 10px"><input id="locationInput" style="width:400px;height:18px;float:left;display:inline;" type="text" />'+
				 '<img id="searchBtn" src="/static/images/addTfeet/searchBtn1.png" style="margin:3px 0px 0px 5px"/></div>'+
				 '<div id="locationMap" style="width: 430px; height: 250px;margin:5px 10px 0px 10px"></div>'+
				 '<div style="width: 430px; height: 150px;margin:5px 10px 0px 10px;z-index:20000">'+
				 '<div name="image" id="dropbox" style="border:3px dashed silver;width:140px;height:140px;float:left;display:inline;margin:0px 10px 0px 0px"></div>'+
				 '<textarea style="height:140px;width:260px;float:left;display:inline;"></textarea>'+
				 '</div>';
	this.centerPoint  = new google.maps.LatLng(39.91, 116.41)
	this.geocoder = new google.maps.Geocoder();
	this.bo={};
	this.addMarker=null;
	this.locationInput = null;
	this.render = function(){
		this.body = jQuery('<div>',{style:"width:450px;height:450px;position:absolute;z-index:10001;background-color:#FFFFFF;"}).append(jQuery.tmpl(this.bodyCfg, this.data));
		var sizeObj = getObjSize(this.body);
		this.body.insertAfter(jQuery.documentMask().bind("maskclose",function(){this.body.remove()}.createDelegate(this)));
		this.body.css({
			top : sizeObj.top,
			left : sizeObj.left
		});
		this.body.click(function(){return false;});
		
		this.locationInput = jQuery("#locationInput");
		jQuery("#searchBtn").click(function(){
			this.queryLatLngFromAddress(jQuery("#locationInput").val());
		}.createDelegate(this));
		//渲染地图
		
		var myOptions = {
			zoom: 11,
			center: this.centerPoint,
			mapTypeId: google.maps.MapTypeId.HYBRID,
			navigationControl: true,
			  navigationControlOptions: {
			    style: google.maps.NavigationControlStyle.SMALL
			  }
		};
		this.locationMap = new google.maps.Map(jQuery("#locationMap")[0], myOptions);
		google.maps.event.addListener(this.locationMap, 'click', function(event) {
		    this.placeMarker(event.latLng);
		}.createDelegate(this));
	};
	
	this.placeMarker = function(location) {
			if(this.addMarker!=null){
				this.addMarker.setMap(null);
			}
			this.bo.long = location.lng();
			this.bo.lat = location.lat();
			this.queryAddressFromLatLng(location);
			this.addMarker = new google.maps.Marker({
		      position: location, 
		      map: this.locationMap,
		      draggable:true
		  });
	}.createDelegate(this);
	
	/**
	 * 根据经纬度查询地址
	 * @param latLng
	 */
	this.queryAddressFromLatLng = function(latLng){
		this.geocoder.geocode({'latLng': latLng}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
		        if (results[1]) {
					this.bo.location=results[0].formatted_address;
			    }
			}
		}.createDelegate(this));
	};
	
	this.queryLatLngFromAddress = function(address){
		this.geocoder.geocode({'address': address}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				
				this.locationMap.setCenter(results[0].geometry.location);
				this.placeMarker(results[0].geometry.location);
			} else {
				alert("Geocode was not successful for the following reason: " + status);
			}
		}.createDelegate(this));
	};

	
	this.initComponent = function(config) {
		Tfeet.apply(this, config);

	};
	this.initComponent(config);
};
Tfeet.widgets.addTfeetWindow.Extends(Tfeet.Base);